<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //写入五行四列的表格，将帖子数组中数据填充到单元格中
    var arr =[
        ["第一条帖子","a","写入五行四列的表格，将帖子数组中数据填充到单元格中"],
        ["第二条帖子","b","写入五行四列的表格，将帖子数组中数据填充到单元格中"],
        ["第三条帖子","c","写入五行四列的表格，将帖子数组中数据填充到单元格中"],
        ["第四条帖子","d","写入五行四列的表格，将帖子数组中数据填充到单元格中"],
        ["第五条帖子","e","写入五行四列的表格，将帖子数组中数据填充到单元格中"],
    ];
    var tbHeight ="500px";
    var tbWidth ="800px";
    document.write("<table border ='1' heigth='"+ tbHeight+ "'width='"+tbWidth+"'" +">");
        function createList(arr){
            for(var i=0;i<arr.length;i++){
                document.write("<tr>");
                    for(var j=0;i<arr[0].length;j++){
                        if (j==2) {
                            arr[i][j] = arr[i][j].slice(0,5)+"....."
                        }
                        document.write("<td>");
                            document.write(arr[i][j]);
                            document.write("</td>");

                    }
                    document.write("</tr>");
            }
        }
        createList(arr);
        document.write("</table>");




/* 
    var text = "这是帖子5，主要内容是";
    var text1 = text.slice(0,5);
    text1 =text1 + "....."
    document.write(text1);
 */

   /*  var text2 ="......";
    console.log(text1 + text2); */

    </script>
</html>